package qsoft.omanga.ui.custom;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import qsoft.omanga.business.entities.Manga;
import qsoft.omanga.common.utils.FileUtil;
import qsoft.omanga.common.utils.Loading;
import qsoft.omanga.ui.R;

/**
 * 
 * @author sontt
 * 
 */
public class ListMangaHolder {
	/**
     * 
     */
	private Context context;
	/**
     * 
     */
	private ImageView iv;
	/**
     * 
     */
	private Manga item;
	/**
     * 
     */
	private LayoutInflater inflater;

	/**
	 * 
	 * @param ctx
	 *            Context
	 * @param item
	 *            Manga
	 */
	public ListMangaHolder(Context ctx, Manga item) {
		this.context = ctx;
		this.item = item;
	}

	/**
	 * 
	 * @param convertView
	 *            View
	 * @return View getRow
	 */
	public View getRow(View convertView) {
		View row = convertView;
		if (row == null) {
			inflater = LayoutInflater.from(context);
			row = inflater.inflate(R.layout.item_listall_manga, null);
			iv = (ImageView) row.findViewById(R.id.itemList_mangaImage);
			row.setTag(this);
		}

		ListMangaHolder rkMangaHolder = (ListMangaHolder) row.getTag();
		rkMangaHolder.iv.setTag(item.getPicLarge());
		Loading.getInstance().forceLoad(rkMangaHolder.iv, item.getId(),
				item.getPicLarge(), FileUtil.IMAGE_LARGE);
		// QueueLoad.getInstance().loadBitmap(key, rkMangaHolder.ivImage);
		// AsyncLoad.getInstance().load(item.getPicLarge(),
		// rkMangaHolder.ivImage);
		return row;
	}
}
